package com.zd.shopping.baseadapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import com.zd.shopping.R;
import com.zd.shopping.viewholder.NuclearGoodsDetailsViewHolder;
import com.zd.shopping.viewholder.NuclearGoodsViewHolder;
import com.zwz.mall.listener.OnItemClickListener;
import com.zwz.mall.viewholder.BaseViewHolder;

import java.util.List;

/**
 * Created by 张默默 on 2020/3/13.
 */

public class NuclearGoodsDetailsAdapter extends RecyclerView.Adapter<BaseViewHolder>{
    private Context mContext;
    private  List arrayList;
    private OnItemClickListener mOnItemClickListener;
    private final LayoutInflater inflater;

    public NuclearGoodsDetailsAdapter(Context context , List list){
        this.arrayList=list;
        this.mContext=context;
        inflater = LayoutInflater.from (context);

    }
    @NonNull
    @Override
    public BaseViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        BaseViewHolder viewHolder=null;
        viewHolder = new NuclearGoodsDetailsViewHolder (inflater.inflate (R.layout.item_details, parent, false));
        ((NuclearGoodsDetailsViewHolder)viewHolder).mOnItemClickListener = mOnItemClickListener;
        ((NuclearGoodsDetailsViewHolder)viewHolder).mContext = mContext;
        return viewHolder;
    }

    @Override
    public void onBindViewHolder(@NonNull BaseViewHolder holder, int position) {
        holder.bindView(position, arrayList.get(position),mContext);
    }

    @Override
    public int getItemCount() {
        if(arrayList==null){
            return 0;
        }
        return arrayList.size();
    }
}
